#include <stdio.h>
#include <string.h>

#define STDIN
//#define DEBUG

int year_days[2] = 
{
    365, 366
};

int month_days[][12] = 
{
    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
};

int type(year)
{
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        return 1;
    else
        return 0;
}

int main()
{
#ifdef STDIN
    freopen("bin/2080.in", "r", stdin);
#endif

    int days;
    int y, m, d;
    int year_type;
    while(1)
    {
        scanf("%d", &days);
        if (days == -1)
            break;

        char week[15];
        switch(days % 7)
        {
            case 0:
                strcpy(week, "Saturday");
                break;
            case 1:
                strcpy(week, "Sunday");
                break;
            case 2:
                strcpy(week, "Monday");
                break;
            case 3:
                strcpy(week, "Tuesday");
                break;
            case 4:
                strcpy(week, "Wednesday");
                break;
            case 5:
                strcpy(week, "Thursday");
                break;
            case 6:
                strcpy(week, "Friday");
                break;
            default:
                break;
        }

        int i;
        for (i = 2000; i <= 9999; ++i)
        {
            year_type = type(i);
#ifdef DEBUG
            printf("year: %d 是 %s\n", i, year_type == 0? "非闰年":"闰年");
#endif
            if (year_days[year_type] <= days)
                days -= year_days[year_type];
            else
                {
                    y = i;
                    break;
                }
        }
        for (i = 0; i < 12; ++i)
        {
#ifdef DEBUG
            printf("year: %d month: %d days: %d\n", y, i+1, days);
#endif
            if (days >= month_days[year_type][i])
                days -= month_days[year_type][i];
            else
            {
                m = i+1;//日期没有0月
                break;
            }
        }
        d = days+1; //日期没有0号

        printf("%4d-%02d-%02d %s\n", y, m, d, week);


    }
    return 0;
}
